<?php

$str = 'This is Hello World of String';

// 1. Length of string
echo strlen($str); // 29
echo "\n\n";

// 2. Want to repeat aany string several times
$str = 'Yes ';
echo str_repeat($str, 3); //Yes Yes Yes
echo "\n\n";

// 3. very common function
//    used to replace any string in hayStack
$str = 'weekendphp@googlegroups.com';
echo str_replace('@', ' at ', $str, $count);
echo "\n\n";

// 4. prints string in reverse order
echo strrev($str); //moc.spuorgelgoog@phpdnekeew
echo "\n\n";

// 5. return part of the string
$str = 'weekendphp@googlegroups.com';
echo strstr($str, '@'); //@googlegroups.com
echo "\n";
echo strstr($str, '@',false); //@googlegroups.com
echo "\n";
echo strstr($str, '@',true); //weekendphp
echo "\n\n";

// 6. get domain name
$str = 'weekendphp@googlegroups.com';
echo substr($str, strpos($str,'@')+1); //@googlegroups.com
echo "\n";
echo substr($str, strpos($str,'@')+1, 3); //@googlegroups.com
$length = strpos($str,'.')  - strpos($str,'@') -1;
echo "Length : $length";
echo "\n";
echo substr($str, strpos($str,'@')+1, $length); //@googlegroups.com
echo "\n\n";
